package Rendering.Utils;
import javax.swing.*;
import java.awt.*;

/** A few utilities that simplify testing of windows in Swing.
 *  1998 Marty Hall, http://www.apl.jhu.edu/~hall/java/
 */

public class WindowUtilities {

  /** A simplified way to see a JPanel or other Container.
   *  Pops up a JFrame with specified Container as the content pane.
   */

  public static JFrame openInJFrame(JFrame frame, Container content,
                                    int width,
                                    int height,
                                    String title,
                                    Color bgColor) {
    frame.setBackground(bgColor);
    content.setBackground(bgColor);
    frame.setSize(width, height);
    frame.setContentPane(content);

    // Fullscreen
//    frame.setExtendedState(Frame.MAXIMIZED_BOTH);
//    frame.setUndecorated(true);

    frame.setVisible(true);

    return(frame);
  }

  /** Uses Color.white as the background color. */

  public static JFrame openInJFrame(JFrame frame, Container content,
                                    int width,
                                    int height,
                                    String title) {
    return(openInJFrame(frame, content, width, height, title, Color.white));
  }

  /** Uses Color.white as the background color, and the
   *  name of the Container's class as the JFrame title.
   */

  public static JFrame openInJFrame(JFrame frame, Container content,
                                    int width,
                                    int height) {
    return(openInJFrame(frame, content, width, height,
                        content.getClass().getName(),
                        Color.white));
  }
}